import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class SimpleGui3C{
	
	JFrame frame;
	
	public static void main(String[] args){
		SimpleGui3C gui = new SimpleGui3C();
		gui.go();
	}
	
	public void go(){
		frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JButton button = new JButton("Change Colors");
		frame.getContentPane().add(BorderLayout.SOUTH, button);
		button.addActionListener(new ColorListener());
		
		JButton botaoRotulo = new JButton("Altera rotulo");
		frame.getContentPane().add(BorderLayout.EAST, botaoRotulo);
		botaoRotulo.addActionListener(new LabelListener());
		
		MyDrawPanel drawPanel = new MyDrawPanel();
		frame.getContentPane().add(BorderLayout.CENTER, drawPanel);
		
		JLabel rotulo = new JLabel("Rotulo");
		frame.getContentPane().add(BorderLayout.WEST, drawPanel);
		
		frame.setSize(300, 300);
		frame.setVisible(true);
	}
	
	class ColorListener implements ActionListener{
		public void actionPerformed(ActionEvent event){
			frame.repaint();
		}
	}
	
	class LabelListener implements ActionListener{
		public void actionPerformed(ActionEvent event){
			rotulo.setText("Ouch !");
		}
	}	
}
